package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.HomeImage;
import com.ytjj.qmyx.admin.model.request.HomeImageRequest;
import com.ytjj.qmyx.admin.model.response.HomeImageResponse;
import com.ytjj.qmyx.admin.service.HomeImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * 
 * @Version: 1.0
 * <p>
 * 首页推荐图片
 */
@RestController
@RequestMapping("/homeImage")
public class HomeImageController {

    @Autowired
    private HomeImageService homeImageService;

    /**
     * 增-改首页弹窗图片
     */
    @PostMapping("/addOrUpdate")
    public CommonResult addOrUpdate(@RequestBody HomeImage homeImage){
        return homeImageService.addOrUpdate(homeImage);
    }

    /**
     * 查首页弹窗图片
     */
    @PostMapping("/list")
    public CommonResult list(@RequestBody HomeImageRequest request){
        return CommonResult.success(homeImageService.list(request));
    }

    /**
     * 删首页弹窗图片
     */
    @PostMapping("/delete")
    public CommonResult delete(@RequestBody HomeImage homeImage){
        return homeImageService.delete(homeImage.getId());
    }

    /**
     * 查
     */
    @GetMapping("/getHomeImage")
    public HomeImageResponse getHomeImage(@RequestParam Integer id){
        return homeImageService.getHomeImage(id);
    }
}
